<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <link rel="stylesheet" type="text/css" href="/static/Admin/plugins/colorpicker/colorpicker.css" media="screen">
    <link rel="stylesheet" type="text/css" href="/static/Admin/custom-plugins/wizard/wizard.css" media="screen">

    <!-- Required Stylesheets -->
    <link rel="stylesheet" type="text/css" href="/static/Admin/bootstrap/css/bootstrap.min.css" media="screen">
    <link rel="stylesheet" type="text/css" href="/static/Admin/css/fonts/ptsans/stylesheet.css" media="screen">
    <link rel="stylesheet" type="text/css" href="/static/Admin/css/fonts/icomoon/style.css" media="screen">

    <link rel="stylesheet" type="text/css" href="/static/Admin/css/mws-style.css" media="screen">
    <link rel="stylesheet" type="text/css" href="/static/Admin/css/icons/icol16.css" media="screen">
    <link rel="stylesheet" type="text/css" href="/static/Admin/css/icons/icol32.css" media="screen">

    <!-- Demo Stylesheet -->
    <link rel="stylesheet" type="text/css" href="/static/Admin/css/demo.css" media="screen">

    <!-- jQuery-UI Stylesheet -->
    <link rel="stylesheet" type="text/css" href="/static/Admin/jui/css/jquery.ui.all.css" media="screen">
    <link rel="stylesheet" type="text/css" href="/static/Admin/jui/jquery-ui.custom.css" media="screen">

    <!-- Theme Stylesheet -->
    <link rel="stylesheet" type="text/css" href="/static/Admin/css/mws-theme.css" media="screen">
    <link rel="stylesheet" type="text/css" href="/static/Admin/css/themer.css" media="screen">

    <!-- 引入 layui -->
    <script src="/static/layui/layui.all.js"></script>
    <link rel="stylesheet" href="/static/layui/css/layui.css">

</head>

<body>

    <div class="mws-panel grid_8">
        <div class="mws-panel-header" style="height: 49px">
            <span>
                <i class="icon-table"></i> 草稿消息箱</span>
        </div>
        <div class="mws-panel-body no-padding">
            <div id="DataTables_Table_1_wrapper" class="dataTables_wrapper" role="grid">
                <div id="DataTables_Table_1_length" class="dataTables_length">
                    <!-- <a href="/announce/Excel" class="btn btn-info" id="excel">导出为Excel文件</a> -->
                </div>

                <form action="/announce/DraftMsgList" method="get">
                    
                    <div class="dataTables_filter" id="DataTables_Table_1_filter">
                        <label>标题:
                            <input type="text" aria-controls="DataTables_Table_1" name="keyword" value="{$keyword}">
                            <input type="submit" class="btn btn-info">
                        </label>
                    </div>
                </form>

                <table class="mws-datatable-fn mws-table dataTable" id="DataTables_Table_1" aria-describedby="DataTables_Table_1_info">
                    <thead>
                        <tr role="row">
                            <th class="" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 275px;" aria-sort="ascending"
                                aria-label="Rendering engine: activate to sort column ascending">编号</th>
                            <th class="" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 405px;" aria-label="Browser: activate to sort column ascending">标题</th>
                            <th class="" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 368px;" aria-label="Platform(s): activate to sort column ascending">内容</th>
                            <th class="" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 368px;" aria-label="Platform(s): activate to sort column ascending">备注信息</th>
                            <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 368px;" aria-label="Platform(s): activate to sort column ascending"
                                id="add_time" data-type="{$order_type}" style="cursor:pointer;">上次编辑时间</th>
                            
                            <th class="" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 368px;" aria-label="Platform(s): activate to sort column ascending">操作</th>
                        </tr>
                    </thead>

                    <tbody>
                        {foreach name="list" item="vo"}
                        <tr class="gradeA odd">
                            <td class="">{$vo.msg_id}</td>
                            <td class="title">{$vo.title}</td>
                            <td class="content">{$vo.content}</td>
                            <td class="">{$vo.remark}</td>
                            <td class="">{$vo.add_time|date="Y-m-d H:i:s",###}</td>
                            <td>
                               <a href="/announce/MsgEdit/id/{$vo.msg_id}" class="btn btn-primary">重新编辑</a>
                               <a href="javascript:;" class="btn btn-success confirm_push" name="{$vo.msg_id}">确认推送</a>
                               <a href="javascript:;" class="btn btn-danger delmsg"  name="{$vo.msg_id}">删除</a>
                            </td>
                        </tr>
                        {/foreach}
                    </tbody>
                </table>
                <div class="dataTables_info" id="DataTables_Table_1_info">总数据条数 {$msg_amount}</div>
                <div class="" id="DataTables_Table_1_paginate" style="text-align: center">
                    {$page}
                </div>
            </div>
        </div>
    </div>



</body>
<!-- JavaScript Plugins -->
<script src="/static/Admin/js/libs/jquery-1.8.3.min.js"></script>
<script src="/static/Admin/js/libs/jquery.mousewheel.min.js"></script>
<script src="/static/Admin/js/libs/jquery.placeholder.min.js"></script>
<script src="/static/Admin/custom-plugins/fileinput.js"></script>

<!-- jQuery-UI Dependent Scripts -->
<script src="/static/Admin/jui/js/jquery-ui-1.9.2.min.js"></script>
<script src="/static/Admin/jui/jquery-ui.custom.min.js"></script>
<script src="/static/Admin/jui/js/jquery.ui.touch-punch.js"></script>

<!-- Plugin Scripts -->
<script src="/static/Admin/plugins/datatables/jquery.dataTables.min.js"></script>
<!--[if lt IE 9]>
        <script src="js/libs/excanvas.min.js"></script>
        <![endif]-->
<script src="/static/Admin/plugins/flot/jquery.flot.min.js"></script>
<script src="/static/Admin/plugins/flot/plugins/jquery.flot.tooltip.min.js"></script>
<script src="/static/Admin/plugins/flot/plugins/jquery.flot.pie.min.js"></script>
<script src="/static/Admin/plugins/flot/plugins/jquery.flot.stack.min.js"></script>
<script src="/static/Admin/plugins/flot/plugins/jquery.flot.resize.min.js"></script>
<script src="/static/Admin/plugins/colorpicker/colorpicker-min.js"></script>
<script src="/static/Admin/plugins/validate/jquery.validate-min.js"></script>
<script src="/static/Admin/custom-plugins/wizard/wizard.min.js"></script>

<!-- Core Script -->
<script src="/static/Admin/bootstrap/js/bootstrap.min.js"></script>
<script src="/static/Admin/js/core/mws.js"></script>

<!-- Themer Script (Remove if not needed) -->
<script src="/static/Admin/js/core/themer.js"></script>

<!-- Demo Scripts (remove if not needed) -->
<script src="/static/Admin/js/demo/demo.dashboard.js"></script>


<script>
    // 排序
    $("#add_time").click(function () {
        var order_type = $(this).attr('data-type');

        order_type = order_type == 1 ? 2 : 1;

        keyword = "{$keyword}" != '' ? "{$keyword}" : '';
      

        var options = {
            url: "__WebSite__/announce/DraftMsgList",
            paramName: "order_type",
            newValue: order_type,
            keyword: keyword,
           
        };
        location.href = generateURL(options);
    });

</script>


<script type="text/javascript">
    var generateURL = function (options) {
        var url = options.url;
        var keyword = options.keyword;

        if (keyword != '') {
            if ("/" != url[url.length - 1]) {
                url += "/";
            }
            url += 'keyword/' + keyword;
        }
        if (-1 == url.indexOf(options.paramName)) {
            if ("/" != url[url.length - 1]) {
                url += "/";
            }
            url += options.paramName + "/" + options.newValue;
        } else {
            var re = new RegExp(options.paramName + "/\\d+");
            url = url.replace(re, options.paramName + "/" + options.newValue);
        }
        // url = url.replace(/[=?&]/g, "/");
        return url;
    };
</script>

<!-- 删除 -->
<script>
    $('.delmsg').on('click',function () {
        var sure = window.confirm('确定删除草稿消息');
    // alert(1);
        var id=$(this).attr('name');
        me=$(this);
        
        if(sure){
            $.post('/announce/MsgDel', { 'id': id }, function (data) {
                    if (data == 1) {
                        me.parents('tr').remove();
                    } else {
                        alert('操作失败，请重新尝试');
                    }
                }
            )
        }
    })
</script>

<!-- 推送 -->
<script>
    $('.confirm_push').on('click',function () {
        var sure=window.confirm('确定推送此条消息');
        var msg_id=$(this).attr('name');

        me=$(this);
        if(sure){
            $.post('/announce/MsgPush', { 'msg_id': msg_id }, function (data) {
                if (data == 1) {
                    // 推送成功
                    // alert('success');
                    me.parents('tr').remove();
                } else {
                    alert('操作失败，请重新尝试');
                }

            })
        }
    })
</script>

</html>